<template>
  <div class="adviserDetail">
    <div class="content">
      <van-cell-group>
        <van-cell title="项目名称" :value="dataList.projectName" />
        <van-cell title="所属企业" :value="dataList.industry" />
        <van-cell title="关联需求" :value="dataList.demandName" />
        <van-cell title="状态">
          <el-button v-if="dataList.status = 0">
            <p @click="changeProjectStatus(dataList.projectId,1)">未完成</p>
          </el-button>
          <el-button v-if="dataList.status = 1">
            <p @click="changeProjectStatus(dataList.projectId,0)">已完成</p>
          </el-button>
        </van-cell>
        <div class="grade">
          <van-cell title="(企业)评价" value style="width:70%" />
          <div v-if="dataList.enterpriseProjectScore !==0">
            <van-rate v-model="dataList.enterpriseProjectScore" color="#ffd21e" :size="15" />
          </div>
          <div v-if="dataList.enterpriseProjectScore === 0">
            <el-button type="text">暂无评分</el-button>
          </div>
        </div>
        <div class="grade">
          <van-cell title="(管理员)评价" value style="width:70%" />
          <div v-if="dataList.adminProjectScore !==0">
            <van-rate v-model="dataList.adminProjectScore" color="#ffd21e" :size="15" />
          </div>
          <div v-if="dataList.adminProjectScore === 0">
            <el-button type="text">暂无评分</el-button>
          </div>
        </div>
        <div class="grade">
          <van-cell title="项目附件" style="width:70%" />
          <div v-if="dataList.docFilesUrl !== ''">
            <a :href="dataList.docFilesUrl">
              <el-button type="text" icon="el-icon-download">下载</el-button>
            </a>
          </div>
          <div v-if="dataList.docFilesUrl === ''">
            <el-button type="text">文件暂缺</el-button>
          </div>
        </div>
      </van-cell-group>
    </div>
  </div>
</template>

<script>
export default {
  created() {
    // console.log(this.$route.query.info);
    this.dataList = this.$route.query.info;
  },
  data() {
    return {
      dataList: {}
    };
  },
  methods:{
     // 修改项目状态
    async changeProjectStatus(id, status) {
      let formdata = new FormData;
      formdata.append('id',id);
      formdata.append('status',status)
      let result = await ReqchangeProjectStatus(formdata);
      const { msg } = result;
      if (msg === "success") {
        this.$message({
          message: "修改项目状态成功",
          type: "success",
        });
        this.dataList.status =status;
      }
    },
  }
};
</script>

<style>
a {
  text-decoration: none;
  color: black;
}
.adviserDetail {
  width: 85%;
  margin: 0 auto;
}
.adviserDetail .content .grade {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>